package com.grp6.game.controller;

import static org.junit.Assert.*;

import java.util.List;

import org.junit.Test;

import com.grp6.game.common.IObserver;
import com.grp6.game.common.InvalidMoveException;
import com.grp6.game.gameactions.IMove;
import com.grp6.game.model.IGameBoard;
import com.grp6.game.model.IGameModel;
import com.grp6.game.model.IPiece;
import com.grp6.game.player.IPlayer;
import com.grp6.game.view.IView;

public class AbstractGameLifecycleTest {
	
	@Test
	public void testRunLifecycle() {
		IGameModel<IView> model = new IGameModel<IView>() {
			
			@Override
			public void removeObserver(List<IObserver> observers) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void notifyObservers() {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public List<IObserver> getObservers() {
				// TODO Auto-generated method stub
				return null;
			}
			
			@Override
			public void addObservers(List<IObserver> observers) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void notifyInvalidMove(InvalidMoveException e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public <P extends IPlayer> List<P> getPlayers() {
				// TODO Auto-generated method stub
				return null;
			}
			
			@Override
			public IGameBoard getGameBoard() {
				// TODO Auto-generated method stub
				return null;
			}
		};
		new AbstractGameLifecycle(model) {
			
			int pass_count = 0;
			@Override
			protected void validate(IMove move) throws InvalidMoveException {
				if (++pass_count==2)
					throw new InvalidMoveException();
			}
			
			@Override
			protected boolean hasGameFinished() { 
				return pass_count>1; 
			}
			
			@Override
			protected IPlayer getNextPlayer() {
				return new IPlayer() {
					@Override
					public void setPieces(List<IPiece> pieces) {}
					@Override
					public void setHasWon(boolean hasWon) {}
					@Override
					public boolean isHasWon() { return false;}
					@Override
					public List<IPiece> getPieces() { return null; }
					@Override
					public IMove getNextMove() { return null; }
				};
			}
			
			@Override
			protected void execute(IMove move) { }
		}.runLifecycle();
	}

}
